import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { UserInfoVO, UserInfoForm, UserInfoQuery } from '@/api/access/user/user-info/types';

/**
 * 查询人员信息列表
 * @param query
 * @returns {*}
 */

export const listUserInfo = (query?: UserInfoQuery): AxiosPromise<UserInfoVO[]> => {
  return request({
    url: '/user/user-info/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询人员信息详细
 * @param userId
 */
export const getUserInfo = (userId: string | number): AxiosPromise<UserInfoVO> => {
  return request({
    url: '/user/user-info/' + userId,
    method: 'get'
  });
};

/**
 * 新增人员信息
 * @param data
 */
export const addUserInfo = (data: UserInfoForm) => {
  return request({
    url: '/user/user-info',
    method: 'post',
    data: data
  });
};

/**
 * 修改人员信息
 * @param data
 */
export const updateUserInfo = (data: UserInfoForm) => {
  return request({
    url: '/user/user-info',
    method: 'put',
    data: data
  });
};

/**
 * 删除人员信息
 * @param userId
 */
export const delUserInfo = (userId: string | number | Array<string | number>) => {
  return request({
    url: '/user/user-info/' + userId,
    method: 'delete'
  });
};

/**
 * 查询用户授权的门禁列表
 * @param userGroupId 用户组ID
 */
export const grantDeviceList = (userGroupId: string | number) => {
  return request({
    url: '/user/groupAccessControl/grantDeviceList/' + userGroupId,
    method: 'get'
  });
};
/**
 * 查询用户授权的门禁关联授权信息
 * @param userGroupId 用户组ID
 */
export const authorizeInfo = (userId: string | number, query?) => {
  return request({
    url: '/user/user-access-control/authorizeInfo/' + userId,
    method: 'get',
    params: query
  });
};
/**
 * 查询用户授权的电梯关联授权信息
 * @param userGroupId 用户组ID
 */
export const elevatorInfo = (userId: string | number) => {
  return request({
    url: '/user/user-elevator/authorizeInfo/' + userId,
    method: 'get'
  });
};
/**
 * 查询用户授权的电梯列表
 * @param userGroupId 用户组ID
 */
export const granElevatorList = (userGroupId: string | number) => {
  return request({
    url: '/user/groupElevator/grantDeviceList/' + userGroupId,
    method: 'get'
  });
};
/**
 * 查询用户授权的电梯列表
 * @param userGroupId 用户组ID
 */
export const authorizeInfoList = (userId: string | number, query) => {
  return request({
    url: '/user/user-elevator/authorizeInfo/' + userId,
    method: 'get',
    params: query
  });
};

/**
 * 新增人员 门禁关联
 * @param data
 */
export const addAccessControl = (data) => {
  return request({
    url: '/user/user-access-control',
    method: 'post',
    data: data
  });
};
/**
 * 新增人员 门禁关联
 * @param data
 */
export const addElevator = (data) => {
  return request({
    url: '/user/user-elevator',
    method: 'post',
    data: data
  });
};
